package basicType;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @author Created by chenxin34 on 2019/9/23 下午1:17.
 */
public class GenericTypeTest {
    public static void main(String[] args) {
        List<A> listA = new ArrayList<A>();
        listA.add(new B());

        processElements(listA);


        List<B> listB = new ArrayList<B>();

        processElements(listB);


        List<C> listC = new ArrayList<C>();

        processElements(listC);

        Map<String, List<? extends A>> nested = new HashMap<>();
        nested.put("a", listC);
        processElementsNested(nested);

        List<? extends A> listNew = new ArrayList<>();
        listNew = listC;
    }

    public static void processElements(List<? extends A> elements){

        for(A a : elements){

            System.out.println(a.getValue());

        }

    }

    public static void processElementsNested(Map<String, List<? extends A>> elements){


    }

    public static class A{
        public int getValue() {
            return 0;
        }
    }
    public static class B extends A{}
    public static class C extends A{}
}
